# -*- coding: utf-8 -*-
# @Time        :2025/4/7 17:28
# @Author      :文刀水寿
# @File        : views.py
"""
 @Description :路由 +  视图函数
"""
# 蓝图
from flask import Blueprint, render_template, request
from ..models.models import *

blog = Blueprint('user', __name__)

# 博客首页
@blog.route('/')
@blog.route('/index/')
def blog_index():
    photos = PhotoModel.query.limit(6)
    categorys = CategoryModel.query.all()
    articles = ArticleModel.query.all()
    commdeds = articles[:4]
    return render_template('home/index.html',
                           photos=photos,
                           categorys=categorys,
                           articles=articles,
                           commdeds=commdeds)


# 博客-我的相册
@blog.route('/photos/')
def bolg_photo():
    photos = PhotoModel.query.all()
    return render_template('home/photos.html',
                           photos=photos)

# 博客-我的日记
@blog.route('/article/')
def blog_article():
    categorys = CategoryModel.query.all()
    articles = ArticleModel.query.all()
    return render_template('home/article.html',
                           categorys=categorys,
                           articles=articles)

# 博客-关于我
@blog.route('/about/')
def blog_about():
    photos = PhotoModel.query.limit(6)
    articles = ArticleModel.query.all()
    return render_template('home/about.html',
                           photos=photos,
                           articles=articles)